package com.example;

public class LC1_2 {
    public static void main(String[] args) {
        int[] nums = {-1,-100,3,99};
        int k = 2;
        rotate(nums, k);
    }

    public static void rotate(int[] nums, int k) {
        int len = nums.length;
        if(len < 2) return;
        k = k % len;
        int[] arr = new int[len];
        int to;
        for(int i = 0; i < len; i++) {
            to = i + k;
            if(to >= len) to -= len;
            arr[to] = nums[i];
        }
        System.arraycopy(arr, 0, nums, 0, len);
    }
}
